package com.jk.service.impl;

import com.jk.service.DealInfoService;
import com.jk.mapper.DealInfoMapper;
import com.jk.util.GetDateInfo;
import com.jk.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

@Service("dealInfoService")
public class DealInfoServiceImpl implements DealInfoService {

    @Autowired
    private DealInfoMapper dealInfoMapper;
    /**
     *根据条件进行分页查询
     * @param page
     * @param rows
     * @param dealInfo
     * @return
     */
    public Map getDealInfo(int page, int rows, DealInfo dealInfo) {
        Map map=new HashMap();
        //根据条件进行分页查询总条数
        int totalCount=dealInfoMapper.getDealInfoCount(dealInfo);
        int start=(page-1)*rows;
        int end=rows;
        //根据条件进行分页查询数据
        List<DealInfo> list=dealInfoMapper.getDealInfo(start,end,dealInfo);
        System.out.println(list);
        map.put("total",totalCount);
        map.put("rows",list);
        return map;
    }

    /**
     * 根据时间倒序查询前七条数据
     * @return
     */
    public List<DealInfo> getInfo(){

        return dealInfoMapper.getInfo();
    }

    /**
     * 三表联查账户管理中的相应数据
     * @return
     */
    public List<Map> getAccountUser(String s) {
        return dealInfoMapper.getAccountUser(s);
    }

    //查询该用户所拥有的银行卡
    public List<Map> getBank(String s) {
        return dealInfoMapper.getBank(s);
    }

    //新增一条数据状态为等待付款
    public void addDeal(DealInfo dealInfo) {
        dealInfoMapper.addDeal(dealInfo);
    }

    //判断支付密码是否正确
    public int getPayPwd(UserAccount userAccount) {
        return dealInfoMapper.getPayPwd(userAccount);
    }

    public void putDeal(DealInfo dealInfo) {
        //将交易状态修改为交易成功
        dealInfoMapper.putDeal(dealInfo);
    }

    //对账户金额进行相应修改
    public void putAccountMoney(UserAccount userAccount) {
        dealInfoMapper.putAccountMoney(userAccount);
    }

    //对对应银行卡金额进行相应修改
    public void putBankMoney(AccountBank accountBank) {
        dealInfoMapper.putBankMoney(accountBank);
    }

    //对账户金额进行增加修改
    public void putAccountMoneyInsert(UserAccount userAccount) {
        dealInfoMapper.putAccountMoneyInsert(userAccount);
    }

    //对对应银行卡金额进行减少修改
    public void putBankMoneyReduce(AccountBank accountBank) {
        dealInfoMapper.putBankMoneyReduce(accountBank);
    }

    //通过邮箱获取对象id
    public UserInfo getOtherEmail(UserInfo userInfo) {
        return dealInfoMapper.getOtherEmail(userInfo);
    }

    //通过手机号获取对象id
    public UserInfo getOtherNumber(UserInfo userInfo) {
        return dealInfoMapper.getOtherNumber(userInfo);
    }

    //查询被转账人真实姓名
    public AuthUserIdcard getRealName(UserInfo userInfo) {
        return dealInfoMapper.getRealName(userInfo);
    }

    //对转账账户金额进行相应减少修改
    public void putSelfAccount(UserAccount userAccount) {
        dealInfoMapper.putSelfAccount(userAccount);
    }

    //对被转账账户金额进行相应增加修改
    public void putOtherAccount(UserInfo userInfo, UserAccount userAccount) {
        dealInfoMapper.putOtherAccount(userInfo,userAccount);
    }

    //在转账到银行卡页面根据银行卡号查询相对持卡人和卡名
    public AccountBank getAccountBank(AccountBank accountBank) {
        return dealInfoMapper.getAccountBank(accountBank);
    }

    //对被转账银行卡金额进行相应增加修改
    public void putOtherBank(AccountBank accountBank, UserAccount userAccount) {
        dealInfoMapper.putOtherBank(accountBank,userAccount);
    }

    //逻辑删除（修改状态放入回收站中）
    public void putDeleteStatus(DealInfo dealInfo) {
        dealInfoMapper.putDeleteStatus(dealInfo);
    }

    //查询当前用户账户余额
    public List<Map> getUserAccountMoney(String s) {
        return dealInfoMapper.getUserAccountMoney(s);
    }

    //查询当前账户的充值记录
    public List<DealInfo> getTopUpInfo(String s) {
        return dealInfoMapper.getTopUpInfo(s);
    }

    //查询当前账户的提现记录
    public List<DealInfo> getDepositInfo(String s) {
        return dealInfoMapper.getDepositInfo(s);
    }

    //回收站批量删除
    public int deleteBatch(List<String> ids) {
        return dealInfoMapper.deleteBatch(ids);
    }

    public List<DealInfo> getTopUpInfo2(String s, int status) {
        return dealInfoMapper.getTopUpInfo2(s,status);
    }

    //回收站展示
    public List<DealInfo> getRecycle() {
        return dealInfoMapper.getRecycle();
    }


}
